﻿using System;
using System.Linq;
using System.Xml.Serialization;
using FileDuplicateRemover.Core;
using Useful.MVP2;

namespace FileDuplicateRemover.Gui
{
    public class DuplicateListViewModel : BaseListModel
    {
        public string RootDirectoryFullName { get; set; }

        public DirectoryEntity RootDirectoryEntity { get; set; }

        [XmlIgnore]
        public DuplicateEntityDescriptionList DuplicateEntityList { get; set; }

        [XmlIgnore]
        public GridItemBindingList GridList { get; set; }


        public DuplicateListViewModel()
        {
            RootDirectoryFullName = "C:\\FDR_TEST";
        }

        public override void Dispose()
        {
        }

        [XmlIgnore]
        public bool IsCollapsed { get; set; }

        [XmlIgnore]
        public bool IsProcessAction { get; set; }

        public string InfoText
        {
            get
            {
                string res;

                if (RootDirectoryEntity != null)
                {
                    long totalEntityInDirectory = RootDirectoryEntity.TotalEntityCount;
                    
                    if (GridList != null)
                    {
                        int totalCount = GridList.Count;
                        int checkedCount = GridList.Count(i => i.Checked);
                        int deletedCount = GridList.Count(i => i.IsDeleted);

                        res = String.Format("Всего элементов: {0}, всего в списке: {1}, отмечено: {2}, удалено: {3}", totalEntityInDirectory, totalCount, checkedCount, deletedCount);
                    }
                    else
                        res = String.Format("Всего элементов: {0}", totalEntityInDirectory);
                }
                else
                    res = "Нет данных";

                return res;
            }
        }

        [XmlIgnore]
        public bool HideEmpty { get; set; }

        [XmlIgnore]
        public int CurrentProgressVal { get; set; }

        public int TotalDirectoryEntity { get; set; }

        [XmlIgnore]
        public bool IsHashCalc { get; set; }

        public string SelectedDataFileFullName { get; set; }
    }
}
